package com.sgb.kjwl.view.ui.adapter.packers;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.SelfTeamAchieveEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import java.util.List;

/**
 * Time:2021/3/15
 * AUTHOR:F_Q
 * Description:工队业绩列表adapter
 */
public class WorkPerformanceAdapter extends BaseRecycleAdapter<SelfTeamAchieveEntity> {

    public WorkPerformanceAdapter(Context context, List<SelfTeamAchieveEntity> datas) {
        super(context, R.layout.item_work_performance, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final SelfTeamAchieveEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        CheckBox checkBox = holder.itemView.findViewById(R.id.checkbox);
        checkBox.setChecked(entity.isIslooks());
        LinearLayout details = holder.itemView.findViewById(R.id.details);
        checkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean islooks = entity.isIslooks();
                entity.setIslooks(!islooks);
                checkedbos.selectData();
                notifyDataSetChanged();
            }
        });
        details.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                checkedbos.detailsData(entity.getNo());
            }
        });
    }
    private OnCheckedChangeCheckBox checkedbos;

    public void setCheckedbos(OnCheckedChangeCheckBox checkedbos) {
        this.checkedbos = checkedbos;
    }

    public interface OnCheckedChangeCheckBox {

        void selectData();

        void detailsData(String no);
    }
}
